package com.ruoyi.resSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.resSys.domain.Workresults;
import com.ruoyi.resSys.service.IWorkresultsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 记录管理Controller
 * 
 * @author binbin
 * @date 2024-05-19
 */
@RestController
@RequestMapping("/resSys/workresults")
public class WorkresultsController extends BaseController
{
    @Autowired
    private IWorkresultsService workresultsService;

    /**
     * 查询记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('resSys:workresults:list')")
    @GetMapping("/list")
    public TableDataInfo list(Workresults workresults)
    {
        startPage();
        List<Workresults> list = workresultsService.selectWorkresultsList(workresults);
        return getDataTable(list);
    }

    /**
     * 导出记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('resSys:workresults:export')")
    @Log(title = "记录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Workresults workresults)
    {
        List<Workresults> list = workresultsService.selectWorkresultsList(workresults);
        ExcelUtil<Workresults> util = new ExcelUtil<Workresults>(Workresults.class);
        util.exportExcel(response, list, "记录管理数据");
    }

    /**
     * 获取记录管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('resSys:workresults:query')")
    @GetMapping(value = "/{resultId}")
    public AjaxResult getInfo(@PathVariable("resultId") Long resultId)
    {
        return success(workresultsService.selectWorkresultsByResultId(resultId));
    }

    /**
     * 新增记录管理
     */
    @PreAuthorize("@ss.hasPermi('resSys:workresults:add')")
    @Log(title = "记录管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Workresults workresults)
    {
        return toAjax(workresultsService.insertWorkresults(workresults));
    }

    /**
     * 修改记录管理
     */
    @PreAuthorize("@ss.hasPermi('resSys:workresults:edit')")
    @Log(title = "记录管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Workresults workresults)
    {
        return toAjax(workresultsService.updateWorkresults(workresults));
    }

    /**
     * 删除记录管理
     */
    @PreAuthorize("@ss.hasPermi('resSys:workresults:remove')")
    @Log(title = "记录管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{resultIds}")
    public AjaxResult remove(@PathVariable Long[] resultIds)
    {
        return toAjax(workresultsService.deleteWorkresultsByResultIds(resultIds));
    }
}
